package com.hzhr.iot.web;

import com.hzhr.iot.login.sdk.model.userCard.UserCardModel;
import com.hzhr.iot.web.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class Global implements CommandLineRunner {
    @Autowired
    RedisUtil redisUtil;

    private String token;

    @Override
    public void run(String... strings) throws Exception {
        //redisUtil.set("cyg", HzhrStringUtils.getGUID());
        Object tokenObj = redisUtil.get("cyg");
        token = tokenObj.toString();
    }

    public String getToken() {
        return token;
    }

    public String getFirstToken() {
        String[] tokenSplit = token.split("_");
        return tokenSplit[0];
    }

    public UserCardModel getUserCard() {
        UserCardModel userCard = new UserCardModel();
        userCard.setUserId(0);
        userCard.setUserName("系统");
        userCard.setUserCode("0");
        userCard.setCompanyId(0);
        userCard.setDeptId(0);
        userCard.setType("3");
        return userCard;
    }
}
